package com.dodo.blog.server.impl;

import com.comvai.auth.server.AuthService;
import com.comvai.services.blob.BlobUploadCallback;
import com.comvai.services.persistence.EntityRegistrar;
import com.comvai.services.persistence.LowLevel;
import com.dodo.blog.server.AccountService;
import com.dodo.blog.server.ArticleService;
import com.dodo.blog.server.CategoryService;
import com.dodo.blog.server.PlaygroundService;
import com.dodo.blog.server.TagService;
import com.google.inject.AbstractModule;
import com.google.inject.multibindings.Multibinder;

import javax.inject.Singleton;

/**
 * @author <a href="mailto:pohorelec@comvai.com">Jozef Pohorelec</a>
 */
public class BlogModule
        extends AbstractModule
{
    @Override
    protected void configure()
    {
        bind( ArticleService.class ).to( ArticleServiceBean.class ).in( Singleton.class );
        bind( AccountService.class ).to( AccountServiceBean.class ).in( Singleton.class );
        bind( AuthService.class ).to( AuthServiceBean.class ).in( Singleton.class );
        bind( TagService.class ).to( TagServiceBean.class ).in( Singleton.class );
        bind( CategoryService.class ).to( CategoryServiceBean.class ).in( Singleton.class );
        bind( PlaygroundService.class ).to( PlaygroundServiceBean.class ).in( Singleton.class );

        bind( BlobUploadCallback.class ).to( BlobUploadCallbackImpl.class ).in( Singleton.class );

        Multibinder<EntityRegistrar> registrar = Multibinder.newSetBinder( binder(), EntityRegistrar.class, LowLevel.class );
        registrar.addBinding().to( EntityRegistration.class );
    }
}